# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=py3-compreffor
pkgver=0.5.1_p1
_upstreamver=${pkgver/_p/.post}
pkgrel=1
pkgdesc="CFF table subroutinizer for FontTools"
url="https://github.com/googlefonts/compreffor"
arch="all"
license="Apache-2.0"
depends="
	py3-fonttools
	python3
	"
makedepends="
	cython
	py3-pytest-runner
	py3-setuptools
	python3-dev
	"
checkdepends="py3-pytest"
source="$pkgname-$_upstreamver.tar.gz::https://github.com/googlefonts/compreffor/archive/$_upstreamver.tar.gz
	0001-Drop-the-setuptools_git_ls_files-dependency.patch
	0002-Drop-setuptools_scm-dep.patch
	"
builddir="$srcdir/compreffor-$_upstreamver"

prepare() {
	default_prepare

	sed -e "s/%%PKGVER%%/$pkgver/" -i setup.cfg
}

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$_upstreamver
	python3 setup.py build_ext --inplace
	python3 setup.py build
}

check() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$_upstreamver
	pytest
}

package() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$_upstreamver
	python3 setup.py install --prefix=/usr --root="$pkgdir"
	rm -rf "$pkgdir"/usr/lib/python3*/site-packages/compreffor/test
}

sha512sums="
1186bdc333806dcc5adb7e119844ce7f74844b9e48f7f240306616eea9ce15c640b0cf560e52918d536fb01ae975b240c59af148964a334af458737af92561b1  py3-compreffor-0.5.1.post1.tar.gz
3fc7f6b9686d1af7e45dd26c43920a7424759cea3c362d79ae72e7c6a36cc4ffb0f71806387a1d897dbdf5cc1ca00bcfc2661622ec9b7013b2ade5b400b4d2c2  0001-Drop-the-setuptools_git_ls_files-dependency.patch
b8e23eb6ac60495206d9d0332ee4667c52157779322c621cfa7a94f5147f93e87dde06d91f8b2640e6e4c4a0091b53535d8e209dcce65f06f3f5f654265f47ec  0002-Drop-setuptools_scm-dep.patch
"
